import type { AddRoleForm, ROLE, UpdateRoleForm } from "@/types/role";
import request from "./request";
import type { RESPONSE } from "@/types/base";
import type { USER } from "@/types/user";

enum API {
  ADD_ROLE = "/manage/role/add",
  GET_ROLES = "/manage/role/list",
  UPDATE_ROLES = "/manage/role/update",
  GET_ROLE_PERM = "/menus",
}

export const reqAddRole = (data: AddRoleForm) =>
  request.post<null, RESPONSE<ROLE>>(API.ADD_ROLE, data);

export const reqGetRoles = () =>
  request.get<null, RESPONSE<ROLE[]>>(API.GET_ROLES);

export const reqUpdateRoles = (data: UpdateRoleForm) =>
  request.post<null, RESPONSE<ROLE>>(API.UPDATE_ROLES, data);

export const reqGetRolePerm = (roleId: string) =>
  request.post<null, RESPONSE<{ menus: string[] }>>(API.GET_ROLE_PERM, {
    roleId,
  });
